#include <kwdb/client.h>
#include <iostream>
#include <vector>
#include <chrono>

int main() {
    kwdb::IngestConfig config;
    config.ingest_endpoint = "127.0.0.1:9090";
    config.timeout_ms = 5000;

    kwdb::KwdbClient client(config);

    // Test batch write with different sizes (10, 100, 500)
    std::vector<int> batch_sizes = {10, 100, 500};

    for (int batch_size : batch_sizes) {
        std::vector<kwdb::Point> points;
        auto base_time = std::chrono::system_clock::now();

        for (int i = 0; i < batch_size; i++) {
            kwdb::Point point("sensor_data");
            point.add_tag("device_id", "batch-sensor-" + std::to_string(i % 10));
            point.add_tag("location", "batch-test");
            point.add_field("temperature", 20.0 + (i % 10));
            point.add_field("humidity", 60.0 + (i % 20));
            point.timestamp(base_time + std::chrono::seconds(i));
            points.push_back(point);
        }

        auto status = client.batch_write(points);
        if (status.ok()) {
            std::cout << "Batch of " << batch_size << " points written successfully!" << std::endl;
        } else {
            std::cout << "Batch of " << batch_size << " failed: " << status.message << std::endl;
            return 1;
        }
    }

    return 0;
}